#region Summary 

// 
// Owner : JackieHan 
// 
// Solution : LearnSolution 
// 
// Project : JackieHan.DotNet.DotNet4NewFeatures 
// 
// File : LazyInitialization.cs 
// 
// CopyRight : Copyright © 2009-2010 XunGu Corporation, All Rights Reserved 
// 
// Summary : 延迟初始化 
// 
// History : 
//			2010-05-26 13:16:42	    Create 
// 

#endregion

#region Using 

using System;
using System.Collections.Generic;
using NUnit.Framework;

#endregion

namespace JackieHan.DotNet.DotNet4NewFeatures
{
    /// <summary> 
    /// 延迟初始化 Lazy[T]
    /// </summary> 
    /// <remarks>
    /// 在获取Value的时候用反射的方法初始化T的值
    /// </remarks>
    [TestFixture]
    public class LazyInitialization
    {
        private class Student
        {
            public int Id
            {
                get; set;
            }

            public string Name
            {
                get; set;
            }
        }

        [Test]
        public void TestLazyInitialization()
        {
            Lazy<Student> student = new Lazy<Student>();
            Console.WriteLine(student);
            student.Value.Id = 23;
            student.Value.Name = "New";
            Console.WriteLine(student);
        }
    }
}
